<?php
	if(!isset($id))
	{
		$set_tanggal 	= set_value("tanggal");
		$set_waktu 		= set_value("waktu");
		$set_keterangan	= set_value("keterangan");
		$set_jenis		= set_value("jenis_gangguan");
	}
	else
	{
		$set_tanggal		= (set_value("tanggal") == "")?($list["TANGGAL"]) : (set_value("tanggal"));
		$set_waktu 			= (set_value("waktu") == "")?($list["WAKTU"]) : (set_value("waktu"));
		$set_keterangan 	= (set_value("keterangan") == "")?($list["KETERANGAN"]) : (set_value("keterangan"));
		$set_jenis 			= (set_value("jenis_gangguan") == "")?($list["JENIS_GANGGUAN"]) : (set_value("jenis_gangguan"));
	}
?>
<style>
label{
	text-align:right;
}
</style>
<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				<h4>
					<span>Form History Trouble</span>
				</h4>
			</div>
			<?php echo form_open($post_action);?>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-lg-3 control-label" for="input">Tanggal & Waktu</label>
					<div class="col-lg-4">
						<?php if(!isset($id)){?>
						<input type="text" id="tanggal" name="tanggal" class="form-control elastic" placeholder="Masukkan Tanggal" value="<?php echo date('d-m-Y')?>">
						<?php }else{?>
						<input type="text" id="tanggal" name="tanggal" class="form-control elastic" placeholder="Masukkan Tanggal" value="<?php echo date('d-m-Y', strtotime($set_tanggal))?>">
						<?php }?>
						<font color="red"><?php echo form_error("tanggal"); ?></font>
					</div>
					<div class="col-lg-4">
						<input id="waktu" class="form-control elastic" type="text" name="waktu" placeholder="Masukkan jam" value="<?=$set_waktu?>" />
						<font color="red"><?php echo form_error("waktu"); ?></font>
					</div>
				</div>
				<br />
				<br />
				<div class="form-group">
					<label class="col-lg-3 control-label" for="textarea">Keterangan</label>
					<div class="col-lg-8">
						<textarea class="form-control elastic" name="keterangan" id="keterangan" rows="5"><?=$set_keterangan?></textarea>
						<font color="red"><?php echo form_error("keterangan"); ?></font>
					</div>
					<br>
				</div>
				<br />
				<br />
				<br />
				<div class="form-group">
				<br />
				<br />
					<label class="col-lg-3 control-label" for="textarea">Jenis Gangguan</label>
					<div class="col-lg-8">
					<?php if(!isset($id)){?>
						<label class="radio-inline">
							<input name="jenis_gangguan" type="radio" id="inlineCheckbox1" value="1"> Jaringan
						</label>
						<label class="radio-inline">
							<input name="jenis_gangguan" type="radio" id="inlineCheckbox1" value="2"> Non Jaringan
						</label>
					<?php }else{?>
						<?php if($set_jenis == 1){?>
							<label class="radio-inline">
								<input name="jenis_gangguan" type="radio" id="inlineCheckbox1" value="1" checked> Jaringan
							</label>
							<label class="radio-inline">
								<input name="jenis_gangguan" type="radio" id="inlineCheckbox1" value="2"> Non Jaringan
							</label>
						<?php }elseif($set_jenis == 2){?>
							<label class="radio-inline">
								<input name="jenis_gangguan" type="radio" id="inlineCheckbox1" value="1"> Jaringan
							</label>
							<label class="radio-inline">
								<input name="jenis_gangguan" type="radio" id="inlineCheckbox1" value="2" checked> Non Jaringan
							</label>
						<?php }?>
					<?php }?>
					</div>
				</div>				
				<br />
				<br />
				<div class="form-group">
					<div class="col-lg-offset-3 col-lg-9">
						<button type="submit" class="btn btn-info">Simpan</button>&nbsp;&nbsp;
						<button type="reset" class="btn btn-warning">Reset</button>&nbsp;&nbsp;
						<button type="button" class="btn btn-default" onClick="kembali()">Kembali</button>&nbsp;&nbsp;
					</div>
				</div>
			</div>
				<?php echo form_close();?>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="<?php echo $this->config->item('plugin_path');?>masked/jquery.maskedinput.js"></script>
<script>
function kembali(){
	document.location="<?php echo site_url("history_trouble/grid_history_trouble")?>";
}
$(document).ready(function (){
	if($('#tanggal').length) {
		$('#tanggal').datepicker({
	        inline: true,
			dateFormat:"dd-mm-yy",
			showOtherMonths:true
	    });
	}
	$("#waktu").mask("99.99");
	// $('#waktu').keypress(function(event) {
    // var code = (event.keyCode ? event.keyCode : event.which);
    // if (!(
            // (code >= 48 && code <= 57) //numbers
            // || (code == 46) //period
        // )
        // || (code == 46 && $(this).val().indexOf('.') != -1)
       // )
        // event.preventDefault();
	// });
});
</script>